import {Service, action} from "adajs";

class ReadingService extends Service {
    defaultData() {
        return {
            info: "",
            loading: true,
            success: true,
            errorMsg: "xxxxxxxx"
        };
    }

    onupdate(current, data) {
        Object.assign(current, data);
        let t = document.createElement('div');
        t.innerHTML = data.info;
        current.info = t.innerText;
    }

    @action("result")
    result(current, {result, msg}) {
        current.loading = false;
        current.success = result;
        current.errorMsg = msg;
    }
}

export default ReadingService;